package com.neusoft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.po.Cart;
import com.neusoft.po.CommonResult;
import com.neusoft.service.CartService;

@RestController
@RequestMapping("/Cart")
@RefreshScope //开启动态刷新
public class CartController {
    @Autowired
    private CartService cartService;

    @GetMapping("/CartList")
    public CommonResult<List> listCart(Cart cart) throws Exception {
    	return new CommonResult<List>(200, "success", cartService.listCart(cart));
    }

    @PostMapping("/CartId")
    public CommonResult<Integer> saveCart(Cart cart) throws Exception {
        return new CommonResult<Integer>(200, "success", cartService.saveCart(cart));
    }

    @PutMapping("/CartId")
    public CommonResult<Integer> updateCart(Cart cart) throws Exception {
        return new CommonResult<Integer>(200, "success", cartService.updateCart(cart));
    }

    @DeleteMapping("/CartId")
    public CommonResult<Integer> removeCart(Cart cart) throws Exception {
        return new CommonResult<Integer>(200, "success", cartService.removeCart(cart));
    }

}